package com.fengxing.ams.web.facade.mouble.resource;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

public interface IUserResourceDAO extends PagingAndSortingRepository<UserResourceVO, Integer>, JpaSpecificationExecutor<UserResourceVO>  {

	@Query("select t from UserResourceVO t where user_Id=:userId and type=:type")
	UserResourceVO findByUserId(@Param("userId")Long userId, @Param("type")String type);

	@Modifying
	@Query(value = "update zyt_user_resource set time=time-1 where user_Id=:userId and type=:type", nativeQuery=true)
	void userResource(@Param("userId")Long userId, @Param("type")String type);

}
